package vista;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

@SuppressWarnings("serial")
public class JanelaMsg extends JFrame implements ActionListener {

	JPanel painel;
	JPanel painelBotao;
	JLabel msg;
	JButton ok;
	
	public JanelaMsg(String titulo, String msg){
		painel = new JPanel(new BorderLayout());
		painelBotao = new JPanel();
		this.msg = new JLabel(msg);
		ok = new JButton("ok");
		
		setSize(400, 100);
		setTitle(titulo);
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		
		painelBotao.add(ok);
		painel.add(this.msg, BorderLayout.CENTER);
		painel.add(painelBotao, BorderLayout.SOUTH);
		ok.addActionListener(this);
		
		painel.setVisible(true);
		add(painel);
		setVisible(true);
	}

	@Override
	public void actionPerformed(ActionEvent evt){
		Object source = evt.getSource();
		
		if (source == ok){
			dispose();
		}
	}
	
}
